const fs = require('fs');
const path = require('path');

// 定义源文件和目标文件路径
const srcConfigPath = path.resolve(__dirname, '../src/config/plugin.config.json');
const publicDirPath = path.resolve(__dirname, '../public');
const publicConfigPath = path.resolve(publicDirPath, 'plugin.config.json');

// 检查源文件是否存在
if (fs.existsSync(srcConfigPath)) {
    // 确保public目录存在
    if (!fs.existsSync(publicDirPath)) {
        fs.mkdirSync(publicDirPath, { recursive: true });
    }

    // 复制文件到public目录
    fs.copyFileSync(srcConfigPath, publicConfigPath);
    console.log('Successfully copied plugin.config.json to public directory');
} else {
    console.error('Source plugin.config.json not found at:', srcConfigPath);
    process.exit(1);
}